import os

dir = r"D:\workbench\ant-python-exercises-100p"
for root, dirs, files in os.walk(dir):
    for file in files:
        if file.endswith(".py"):
            fpath = os.path.join(root, file)
            with open(fpath, encoding="utf8") as f:
                print(fpath, len(f.readlines()))
